package idv.arthur.JDBC;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class DBschemaChk {

	public static void main(String[] args) {

		Connection conn = null;
		PreparedStatement ps = null;
		ResultSet rs = null;
		try {
			System.out.print("Connecting...");
			System.out.println("OK");
			Class.forName("com.mysql.jdbc.Driver");
			conn = DriverManager.getConnection(
					"jdbc:mysql://10.144.136.54:3306/sysflow", "Arthur",
					"abcd1234");
			DatabaseMetaData meta = conn.getMetaData();
			
			rs = meta.getTables(null, null, null,
					new String[] { "TABLE" });
			System.out.println("List of tables: ");
			while (rs.next()) {
				for(int i=1; i<11;i++) {
					System.out.print(rs.getString(i)+", ");
				}
				System.out.println();
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (rs != null) { rs.close(); }
				if (ps != null) { ps.close(); }
				if (conn != null) { conn.close(); }
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

}
